<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>日常安排</title>
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/xadmin.js"></script>
</head>
<body>
<table  class="layui-table" >
    <thead>
    <th>编号</th>
    <th>客户</th>
    <th>经理</th>
    <th>内容安排</th>
    <th>创建日期</th>
    <th>是否完成</th>
    <th>操作</th>
    </thead>
    <tbody>
    <tr th:each="i:${info.list}">
        <td th:text ="${i.dayId}"></td>
        <td th:text ="${i.dayUserName}"></td>
        <td th:text ="${i.dayManager}"></td>
        <td th:text ="${i.dayText}"></td>
        <td th:text ="${i.dayTime}"></td>
        <td th:text ="${i.dayFinish}"></td>
        <td>
            <button class="layui-btn layui-btn-normal" type="button" onclick="tag(this)" >标记完成</button>
            <button class="layui-btn layui-btn-normal" type="button" onclick="dailyDel(this)" >删除</button>
        </td>
    </tr>
    </tbody>
</table>
<div style="margin-top: 20px" class="x-so">
    <button class="layui-btn layui-btn-normal" type="button" onclick="add(this)">新增</button>
    <a class="layui-btn layui-btn-normal" th:href="@{/manager/dailyEvent(page=${info.pre})}" >上一页</a>
    第<span th:text="${info.cur}"></span>页
    <a class="layui-btn layui-btn-normal" th:href="@{/manager/dailyEvent(page=${info.next})}" >下一页</a>
    共<span th:text="${info.totalPage}"></span>页/
    <span th:text="${info.total}"></span>条数据

</div>
</body>
</html>
<script>
    //打开新增页面的方法
    function add(obj){
        //打开新增弹窗
        x_admin_show("新增","/manager/dailyAdd",800,600);
    }

    //标记完成
    function tag(obj) {
        //获取当前选中行的dayId值
        var id=$(obj).parent().parent().find("td").eq(0).text();
        //用提示框确定用户是否删除
        layer.confirm("标记完成?",{icon:3,title:"警告"},function (index) {
            $.ajax({
                url:" /manager/tag",
                type:"get",
                data:{"dayId":id},
                dataType:"json",//返回的数据类型
                success:function (data) {
                    layer.alert(data.info,function () {
                        parent.window.location.href=parent.window.location.href;
                    })
                    //关闭
                    layer.close(index);
                }
            })
        })
    }

    //删除
    function dailyDel(obj) {
        //获取当前选中行的userId值
        var id=$(obj).parent().parent().find("td").eq(0).text();
        //用提示框确定用户是否删除
        layer.confirm("你确定要删除吗?",{icon:3,title:"警告"},function (index) {
            $.ajax({
                url:" /manager/dailyDel",
                type:"get",
                data:{"dayId":id},
                dataType:"json",//返回的数据类型
                success:function (data) {
                    layer.alert(data.info,function () {
                        parent.window.location.href=parent.window.location.href;
                    })
                    /*if(data.info=="删除成功"){
                        //刷新
                        $(obj).parent().parent().remove();
                    }*/
                    //关闭
                    layer.close(index);
                }
            })
        })
    }

</script>